
close all;

%% Fixed 12V output voltage at different duty ratios
%% Without diode
%     
    voltage_current_duty_deadtime=[ 12 4 50 1;
                                    12 4 60 1;
                                    12 4 70 1;
                                    12 4 80 1;
                                    12 4 90 1;
                                            ];
[number_of_plots ~]=size(voltage_current_duty_deadtime);
figure;
cc=hsv(number_of_plots);
marker={'x-'; 'o-';'^-';'*-';'s-'};
legendInfo={};

for i=1:number_of_plots
    file=sprintf('./SC_Regulation_%iVout_%iA_%iduty_%ideadtime.dat',voltage_current_duty_deadtime(i,:))
    M = csvread(file,1,0);
    M=M(2:end,:);
    Ploss=M(:,5)-M(:,6);
    efficiency=M(:,6)./M(:,5);
    Iout=M(:,4);
     plot(Iout,efficiency*100,marker{i},'color',cc(i,:),'LineWidth',0.75);
%    plot(Iout.^2,Ploss,marker{i},'color',cc(i,:),'LineWidth',0.75);
    hold all;
%     legendInfo{i} = sprintf('%iV %iA duty%i deadtime%i',voltage_current_duty_deadtime(i,:));
end
legendInfo = {'V{in} = 150 V','V{in} = 130 V','V{in} = 105 V','V{in} = 95 V','V{in} = 85 V'}

%%
xlabel('Load current (A)');
% ylabel('Power loss (W)');
ylabel('Efficiency (%)');
title('Efficiency of the converter with a constant 12 V output.')
legend(legendInfo,'Location','SouthEast');
grid on;
 ylim([90 97]);
% xlim([0 410]);

% set(gcf, 'Position', [200 200 450 300])
% set(gcf,'PaperPositionMode','auto')
% print('-depsc2', './efficiency_regulated_exp');


%% Fixed 18V output voltage at different duty ratios
%% Without diode
%     
    voltage_current_duty_deadtime=[ 
                                    18 4 70 1;
                                    18 4 80 1;
                                    18 4 90 1;
                                            ];
[number_of_plots ~]=size(voltage_current_duty_deadtime);
figure;
cc=hsv(number_of_plots);
marker={'x-'; 'o-';'^-';'*-';'s-'};
legendInfo={};

for i=1:number_of_plots
    file=sprintf('./SC_Regulation_%iVout_%iA_%iduty_%ideadtime.dat',voltage_current_duty_deadtime(i,:))
    M = csvread(file,1,0);
    M=M(2:end,:);
    Ploss=M(:,5)-M(:,6);
    efficiency=M(:,6)./M(:,5);
    Iout=M(:,4);
     plot(Iout,efficiency*100,marker{i},'color',cc(i,:),'LineWidth',0.75);
%    plot(Iout.^2,Ploss,marker{i},'color',cc(i,:),'LineWidth',0.75);
    hold all;
%     legendInfo{i} = sprintf('%iV %iA duty%i deadtime%i',voltage_current_duty_deadtime(i,:));
end
legendInfo = {'V{in} = 150 V','V{in} = 130 V','V{in} = 105 V','V{in} = 95 V','V{in} = 85 V'}

%%
xlabel('Load current (A)');
% ylabel('Power loss (W)');
ylabel('Efficiency (%)');
title('Efficiency of the converter with a constant 12 V output.')
legend(legendInfo,'Location','SouthEast');
grid on;
 ylim([90 97]);
% xlim([0 410]);


%% Fixed 12V output voltage at different duty ratios
%% With Diode
%     
    voltage_current_duty_deadtime=[ 12 4 70 1;
                                    12 4 80 1;
                                    12 4 90 1;
                                            ];
[number_of_plots ~]=size(voltage_current_duty_deadtime);
figure;
cc=hsv(number_of_plots);
marker={'x-'; 'o-';'^-';'*-';'s-'};
legendInfo={};

for i=1:number_of_plots
    file=sprintf('./SC_Regulation_with_diode_%iVout_%iA_%iduty_%ideadtime.dat',voltage_current_duty_deadtime(i,:))
    M = csvread(file,1,0);
    M=M(2:end,:);
    Ploss=M(:,5)-M(:,6);
    efficiency=M(:,6)./M(:,5);
    Iout=M(:,4);
     plot(Iout,efficiency*100,marker{i},'color',cc(i,:),'LineWidth',0.75);
%    plot(Iout.^2,Ploss,marker{i},'color',cc(i,:),'LineWidth',0.75);
    hold all;
%     legendInfo{i} = sprintf('%iV %iA duty%i deadtime%i',voltage_current_duty_deadtime(i,:));
end
legendInfo = {'V{in} = 150 V','V{in} = 130 V','V{in} = 105 V','V{in} = 95 V','V{in} = 85 V'}

%%
xlabel('Load current (A)');
% ylabel('Power loss (W)');
ylabel('Efficiency (%)');
title('Efficiency of the converter with a constant 12 V output.')
legend(legendInfo,'Location','SouthEast');
grid on;
 ylim([90 97]);
% xlim([0 410]);